In [1]:
from konfoo import Index, Byteorder, Stream
Item type of the field
class.
In [2]:
Stream.item_type
Out[2]:
Checks if the field
class is a bit
field.
In [3]:
Stream.is_bit()
Out[3]:
Checks if the field
class is a boolean
field.
In [4]:
Stream.is_bool()
Out[4]:
Checks if the field
class is a decimal
number field.
In [5]:
Stream.is_decimal()
Out[5]:
Checks if the field
class is a floating point
number field.
In [6]:
Stream.is_float()
Out[6]:
Checks if the field
class is a pointer
field.
In [7]:
Stream.is_pointer()
Out[7]:
Checks if the field
class is a stream
field.
In [8]:
Stream.is_stream()
Out[8]:
Checks if the field
class is a string
field.
In [9]:
Stream.is_string()
Out[9]:
In [10]:
stream = Stream(size=0)
In [11]:
stream = Stream()
In [12]:
stream
Out[12]:
In [13]:
str(stream)
Out[13]:
In [14]:
repr(stream)
Out[14]:
In [15]:
stream.name
Out[15]:
In [16]:
stream.index
Out[16]:
Byte index
of the field
within the byte stream
.
In [17]:
stream.index.byte
Out[17]:
Bit offset relative to the byte index
of the field
within the byte stream
.
In [18]:
stream.index.bit
Out[18]:
Absolute address of the field
within the data source
.
In [19]:
stream.index.address
Out[19]:
Base address of the byte stream
within the data source
.
In [20]:
stream.index.base_address
Out[20]:
Indexes the field
and returns the index
after the field
.
In [21]:
stream.index_field(index=Index())
Out[21]:
In [22]:
stream.alignment
Out[22]:
Byte size of the aligned field group
.
In [23]:
stream.alignment.byte_size
Out[23]:
Bit offset of field
in the aligned field group
.
In [24]:
stream.alignment.bit_offset
Out[24]:
In [25]:
stream.bit_size
Out[25]:
In [26]:
len(stream)
Out[26]:
In [27]:
bool(stream)
Out[27]:
In [28]:
stream.byte_order
Out[28]:
In [29]:
stream.byte_order.value
Out[29]:
In [30]:
stream.byte_order.name
Out[30]:
In [31]:
stream.byte_order = 'auto'
In [32]:
stream.byte_order = Byteorder.auto
Returns the stream field
value as a lowercase hexadecimal encoded string.
In [33]:
stream.value
Out[33]:
Returns the stream field
value as a number of bytes.
In [34]:
bytes(stream)
Out[34]:
In [35]:
bytes(stream).hex()
Out[35]:
Returns the stream field
value as a lowercase hexadecimal encoded string.
In [36]:
stream.hex()
Out[36]:
Returns the meatadata
of the field
as an ordered dictionary.
In [37]:
stream.describe()
Out[37]:
Resizing the stream
field.
In [38]:
stream.resize(10)
View of the stream
field.
In [39]:
stream
Out[39]:
Index of the stream
field.
In [40]:
stream.index
Out[40]:
Name of the stream
field.
In [41]:
stream.name
Out[41]:
Alignment of the stream
field.
In [42]:
stream.alignment
Out[42]:
Bit size of the stream
field.
In [43]:
stream.bit_size
Out[43]:
Byte length of the stream
field.
In [44]:
len(stream)
Out[44]:
In [45]:
bool(stream)
Out[45]:
Value of the stream
field
In [46]:
stream.value
Out[46]:
In [47]:
bytes(stream)
Out[47]:
In [48]:
bytes(stream).hex()
Out[48]:
In [49]:
stream.hex()
Out[49]:
In [50]:
stream.deserialize(bytes.fromhex('0102030405060708090a'))
Out[50]:
In [51]:
stream.value
Out[51]:
In [52]:
bytes(stream)
Out[52]:
In [53]:
bytes(stream).hex()
Out[53]:
In [54]:
stream.hex()
Out[54]:
In [55]:
buffer = bytearray()
In [56]:
stream.value = '0102030405060708090a'
In [57]:
stream.value = b'\x01\x02\x03\x04\x05\x06\x07\x08\t\n'
In [58]:
stream.serialize(buffer)
Out[58]:
In [59]:
buffer.hex()
Out[59]:
In [60]:
bytes(stream).hex()
Out[60]:
In [ ]: